import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QDesktopWidget
from PyQt5.QtGui import QIcon

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.resize(400, 200)
        self.status = self.statusBar()
        self.status.showMessage("这是状态栏", 5000)

        self.setWindowTitle("PyQt MainWindows例子")

        self.move_to_screen_center()

    def move_to_screen_center(self):
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        print(screen)
        print(size)
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    form = MainWindow()
    form.show()

    sys.exit(app.exec_())